#include <util\AutomaticInstallation.au3>

Global $InstallProgramPath = "C:\Program Files\PowerISO\PowerISO.exe"
Global $InstallFolder      = "C:\Program Files\PowerISO"
Global $SetupFile = "PowerISO33.exe"
Global $UninstallPath = "C:\Program Files\PowerISO\uninstall.exe"

Main($InstallProgramPath, $InstallFolder, $SetupFile, $UninstallPath)

Func InstallImpl($SetupPath) 
	Dim $Title = ""
	
	RunSetupFile($SetupPath)

	$Title = "PowerISO 3.3 Setup: Installation Folder"
	$Text = "&Install"
	WinWaitActive($Title, $Text)
	Send("!I")
	Sleep($SleepDelay)
	
	$Title = "PowerISO 3.3 Setup: Completed"
	$Text = "Completed"
	WinWaitActive($Title, $Text)
	Send("!N")
	Sleep($SleepDelay)
	
	$Title = "PowerISO 3.3 Setup: Options"
	WinWaitActive($Title)
	Send("{TAB}")
	Send("{TAB}")
	Send("{SPACE}")
	Send("!C")
	Sleep($SleepDelay)

	$Title = "PowerISO 3.3 Setup"
	$Text = "You need reboot your computer to finish the installation. Do you want to reboot now?"
	WinWaitActive($Title, $Text)
	Sleep($SleepDelay)
	Send("{TAB}")
	Sleep($SleepDelay)
	Send("{Enter}")
	WinWaitClose($Title)

	$Executable = "c:\Program Files\PowerISO\PowerISO.exe"
	Run($Executable)

	$Title = "PowerISO"	
	$Text = "Enter registration code..."
	$retVal = WinWaitActive($Title, $Text,3)
	If $retVal <> 0 Then
		WinClose($Title, $Text)
	EndIf
	
 	$Title = "PowerISO(Unregistered Copy) - New Image File.daa"
   	WinWaitActive($Title)
   	Send("!H")
   	Send("R")
	
	$Title = "Registration"
	$retVal = WinWaitActive($Title,"",3)
	If $retVal <> 0 Then
		Send("{CAPSLOCK on}")
   	
		; TeaM CzW
		Send("TeaM CzW")
		
		Send("{TAB}")
		
		; C2U29-3RC84-C8HHY-WEQLE-FHWFM
		Send("C2U29")
		Send("3RC84")
		Send("C8HHY")
		Send("WEQLE")
		Send("FHWFM")
		      
		Send("{Tab}")
		Send("{Tab}")
		Send("{Tab}")
		Send("{Enter}")
		WinWaitClose($Title)
		
		$Title = "PowerISO"
		$Text = "Thank you for your registration."
		$retVal = WinWaitActive($Title, $Text,3)
		If $retVal <> 0 Then
			Sleep($SleepDelay)
			Send("{Enter}")
			Sleep($SleepDelay)
		EndIf
	EndIf
	
	$Title = "PowerISO - New Image File.daa"
	$retVal = WinWaitActive($Title)
	Sleep($SleepDelay)
	Send("{!F}")
	Sleep($SleepDelay)
	Send("{X}")
	Sleep($SleepDelay)
	WinWaitClose($Title)

	Return True
EndFunc

Func UninstallImpl($UninstallPath)
	Dim $Title = ""
	Run($UninstallPath)

	$Title = "PowerISO 3.3 Uninstall: Confirmation"
	$Text = "&Uninstall"
	WinWaitActive($Title, $Text)
	Send("!U")
	Sleep($SleepDelay)
	
	$Title = "PowerISO 3.3 Uninstall"
	$Text = "You need reboot your computer to finish the uninstallation. Do you want to reboot now?"
	$retVal = WinWaitActive($Title, $Text, 3)
	If $retVal <> 0 Then
		Sleep($SleepDelay)
		Send("{Tab}")
		Sleep($SleepDelay)
		Send("{Enter}")
		Sleep($SleepDelay)
	EndIf
	
	$Title = "PowerISO 3.3 Uninstall: Completed"
	$Text = "&Close"
	WinWaitActive($Title, $Text)
	Sleep($SleepDelay)
	Send("!C")
	Sleep($SleepDelay)	
	
	Return True
EndFunc




